﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Wpg_VoteSys.Models.Database
{
    public partial class Wpg_VoteSysContext : DbContext
    {
        public Wpg_VoteSysContext()
        {
        }

        public Wpg_VoteSysContext(DbContextOptions<Wpg_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Category> Categories { get; set; }
        public virtual DbSet<Firmbiao> Firmbiaos { get; set; }
        public virtual DbSet<Item> Items { get; set; }
        public virtual DbSet<Prizewin> Prizewins { get; set; }
        public virtual DbSet<User> Users { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Wpg_VoteSys;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Category>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("Category");

                entity.Property(e => e.Categoryname)
                    .IsRequired()
                    .HasMaxLength(10)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<Firmbiao>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("Firmbiao");

                entity.Property(e => e.Firmname)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Logo)
                    .IsRequired()
                    .HasMaxLength(200)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<Item>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("Item");

                entity.Property(e => e.Category)
                    .IsRequired()
                    .HasMaxLength(2);

                entity.Property(e => e.Through)
                    .HasMaxLength(3)
                    .HasColumnName("through");
            });

            modelBuilder.Entity<Prizewin>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("Prizewin");

                entity.Property(e => e.Award).HasColumnName("award");

                entity.Property(e => e.Image1)
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Image2)
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Image3)
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Image4)
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Image5)
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Specifics)
                    .IsRequired()
                    .HasMaxLength(100)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("User");

                entity.Property(e => e.CreatTime).HasColumnType("datetime");

                entity.Property(e => e.Email)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Password)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Salt)
                    .HasMaxLength(4)
                    .IsFixedLength(true);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
